package cn.ubeta.b2c.user.address;

import android.content.Context;
import android.os.Bundle;

import cn.ubeta.b2c.R;
import cn.ubeta.b2c.common.AnalyseActivity;
import cn.ubeta.b2c.utils.TitleBarHelper;

/**
 * Created by denny on 16/9/5.
 */

public class EditAddressActivity extends AnalyseActivity {

    private final static String ARG_ADDRESS_ID = "address_id";

    private int mAddressId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, R.layout.activity_address_edit);

        mAddressId = getIntent().getIntExtra(ARG_ADDRESS_ID, 0);

        TitleBarHelper.setTitle(this, mAddressId == 0 ? "添加地址" : "编辑地址");
        TitleBarHelper.setRightAction(this, "保存", v -> saveAddress());
    }

    /**
     * 保存地址
     */
    private void saveAddress() {
        // TODO 保存地址
    }

    /**
     * 编辑/添加地址
     * @param context
     * @param addressId 为0时表示添加地址
     */
    public static void gotoAddressEdit(Context context, int addressId) {
        Bundle data = new Bundle();
        data.putInt(ARG_ADDRESS_ID, addressId);
        gotoActivity(context, EditAddressActivity.class, data);
    }

}
